package behavioralPattern.command.example01;

import java.util.ArrayList;

/**
 * 调用者角色
 *  -- invoker
 */
public class Waiter {

    // 可以持有多个命令对象
    private ArrayList<Command> commands = new ArrayList<>();

    public void addCommand(Command command) {
        this.commands.add(command);
    }

    // 发出指令
    public void orderUp(){
        System.out.println("厨师来做饭");
        for (Command command : commands) {
            if (command != null){
                command.execute();
            }
        }
    }
}
